package com.jackaltsc.mydemolist.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.jackaltsc.mydemolist.R;

/**
 * Spinner填充数据有两种
 * 一种是直接在布局文件里用entries填充字符串数组
 * 还有一种是在代码里用ArrayAdapter提供数据
 * <p>
 * Created by JackalTsc on 2016/7/13.
 */
public class SpinnerActivity extends Activity {

    private Spinner mSpinner;

    private ArrayAdapter<String> mAdapter;

    private String[] mData = new String[]{
            "杭州电子科技大学", "浙江大学", "清华大学", "上海交通大学"
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_activity_spinner);

        initView();

    }

    private void initView() {

        mSpinner = (Spinner) findViewById(R.id.sp_test_code);

        mAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,
                mData);

        mSpinner.setAdapter(mAdapter);

    }
}
